
%% initialize
clear all;
close all;
clc

cd  E:\ReplicateBuild\02_code\03_matlab


% diary('mixed_logit')
% diary off
rng(328120)


   
    
  %% principalest, estimated teacher pref
 
 clear 

 % bring in first best if we max output of disadvantag

load  '../../01_data/05_temp/model/alloc_teach_fracdis_princ_va_unrestr_baseline'
clear i* jass* teach_school* random* jrank*

firstbest_outputdis=mean(firstbest_school); 

clear stable_school_propose  stable_teach_propose  firstbest_school 
 
   load '../../01_data/05_temp/model/cfs_princ'
   
   stable_teach_fd_store2=sortrows(stable_teach_fd_store,1);
   stable_teach_fd_store3=[stable_teach_fd_store2(1:2,:);  stable_teach_fd_store2(5:end,:)];
  
    figure(6)
    plot(stable_teach_fd_store(:,1),  stable_teach_fd_store(:,4) ,'--r','LineWidth',2.0      )
    hold on
    plot(stable_teach_fdva_store(:,1),  stable_teach_fdva_store(:,4) ,':b','LineWidth',2.0      ) 
    plot(  stable_teach_fdva_store(:,1), ones(length(stable_teach_fd_store(:,1)))*(firstbest_outputdis(:,4)), '--k','LineWidth',1.0)    
    hold off
    set(gca,'FontSize',15)
    ylim([-0.06 0.04])
    xlabel('Minutes of commute time per teacher')
    ylabel('Disadvantaged students')
    xlim([0 150])
    ylim([-0.08 0.04])    
    % title('subsidize output')
    legend('disadv.','disadv. \times VA','Location','SouthEast')
    saveas(gcf,'../../03_output/figures/cf_dist.png') 
    
    
        figure(61)
    plot(stable_teach_fd_store(:,1),  stable_teach_fd_store(:,4) ,'--k','LineWidth',2.0      )
    hold on
    plot(stable_teach_fdva_store(:,1),  stable_teach_fdva_store(:,4) ,':k','LineWidth',2.0      ) 
    plot(  stable_teach_fdva_store(:,1), ones(length(stable_teach_fd_store(:,1)))*(firstbest_outputdis(:,4)), '--k','LineWidth',1.0)    
    hold off
    set(gca,'FontSize',15)
    ylim([-0.06 0.04])
    xlabel('Minutes of commute time per teacher')
    ylabel('Disadvantaged students')
    xlim([0 150])
    ylim([-0.08 0.04])    
    % title('subsidize output')
    legend('disadv.','disadv. \times VA','Location','SouthEast')
    saveas(gcf,'../../03_output/figures/cf_dist_BW.eps')  
    
    
    
  %%  VA preferences
  %bring in first best if we max output of disadvantag

load  '../../01_data/05_temp/model/alloc_teach_fracdis_princ_va_unrestr_baseline'
clear i* jass* teach_school* random* jrank*

firstbest_outputdis=mean(firstbest_school); 

clear stable_school_propose  stable_teach_propose firstbest_school

 load '../../01_data/05_temp/model/cfs_va'

 
 stable_teach_fdva_store2=[stable_teach_fdva_store(1:4,:); stable_teach_fdva_store(6:end,:)];
     
    figure(6)
    plot(stable_teach_fd_store(:,1),  stable_teach_fd_store(:,4) ,'--r','LineWidth',2.0      )
    hold on
    plot(stable_teach_fdva_store(:,1),  stable_teach_fdva_store(:,4) ,':b','LineWidth',2.0      ) 
    plot(  stable_teach_fdva_store(:,1), ones(length(stable_teach_fd_store(:,1))).*(firstbest_outputdis(:,4)), '--k','LineWidth',1.0) 
    hold off
    set(gca,'FontSize',15)
    xlabel('Minutes of commute time per teacher')
    ylabel('Disadvantaged students ')
    xlim([0 150])
    ylim([-0.08 0.04])
    legend('disadv.','disadv. \times VA','Location','SouthEast')
    saveas(gcf,'../../03_output/figures/cf_va_overall_dist.png') 
    
    
        figure(62)
    plot(stable_teach_fd_store(:,1),  stable_teach_fd_store(:,4) ,'--k','LineWidth',2.0      )
    hold on
    plot(stable_teach_fdva_store(:,1),  stable_teach_fdva_store(:,4) ,':k','LineWidth',2.0      ) 
    plot(  stable_teach_fdva_store(:,1), ones(length(stable_teach_fd_store(:,1))).*(firstbest_outputdis(:,4)), '--k','LineWidth',1.0) 
    hold off
    set(gca,'FontSize',15)
    xlabel('Minutes of commute time per teacher')
    ylabel('Disadvantaged students ')
    xlim([0 150])
    ylim([-0.08 0.04])
    legend('disadv.','disadv. \times VA','Location','SouthEast')
    saveas(gcf,'../../03_output/figures/cf_va_overall_dist_BW.eps') 
      

     